{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3036ad45",
   "metadata": {},
   "source": [
    "# 生成字体步骤\n",
    "\n",
    "- 获取字符列表\n",
    "- 从字体中提取子集，合并成一个完整的字体文件\n",
    "- 生成不同 size 与 bpp 的点阵字体"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "93205a30",
   "metadata": {},
   "source": [
    "## 获取字符列表\n",
    "\n",
    "这里使用 DeepSeek 的词表来提取常用字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "45820776",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: modelscope in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (1.28.1)\n",
      "Requirement already satisfied: transformers in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (4.54.1)\n",
      "Requirement already satisfied: requests>=2.25 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from modelscope) (2.32.3)\n",
      "Requirement already satisfied: setuptools in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from modelscope) (75.8.0)\n",
      "Requirement already satisfied: tqdm>=4.64.0 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from modelscope) (4.67.1)\n",
      "Requirement already satisfied: urllib3>=1.26 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from modelscope) (2.4.0)\n",
      "Requirement already satisfied: filelock in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from transformers) (3.18.0)\n",
      "Requirement already satisfied: huggingface-hub<1.0,>=0.34.0 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from transformers) (0.34.3)\n",
      "Requirement already satisfied: numpy>=1.17 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from transformers) (2.2.6)\n",
      "Requirement already satisfied: packaging>=20.0 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from transformers) (25.0)\n",
      "Requirement already satisfied: pyyaml>=5.1 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from transformers) (6.0.2)\n",
      "Requirement already satisfied: regex!=2019.12.17 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from transformers) (2025.7.34)\n",
      "Requirement already satisfied: tokenizers<0.22,>=0.21 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from transformers) (0.21.4)\n",
      "Requirement already satisfied: safetensors>=0.4.3 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from transformers) (0.5.3)\n",
      "Requirement already satisfied: fsspec>=2023.5.0 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from huggingface-hub<1.0,>=0.34.0->transformers) (2025.7.0)\n",
      "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from huggingface-hub<1.0,>=0.34.0->transformers) (4.14.1)\n",
      "Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from huggingface-hub<1.0,>=0.34.0->transformers) (1.1.5)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from requests>=2.25->modelscope) (3.4.2)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from requests>=2.25->modelscope) (3.10)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (from requests>=2.25->modelscope) (2025.8.3)\n"
     ]
    }
   ],
   "source": [
    "# 安装 modelscope\n",
    "!pip install modelscope transformers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c3acd714",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading Model from https://www.modelscope.cn to directory: /home/terrence/.cache/modelscope/hub/models/deepseek-ai/DeepSeek-R1-0528\n"
     ]
    }
   ],
   "source": [
    "from tqdm import tqdm\n",
    "from modelscope import AutoTokenizer\n",
    "\n",
    "model_name = \"deepseek-ai/DeepSeek-R1-0528\"\n",
    "\n",
    "# load the tokenizer and the model\n",
    "tokenizer = AutoTokenizer.from_pretrained(model_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e4ab8eb6",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 128815/128815 [00:00<00:00, 365899.91it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total unique chars: 7404\n",
      "Wrote 7404 unique characters to unique_chars.txt (sorted by token ID)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "\n",
    "# 创建临时目录\n",
    "if not os.path.exists(\"build\"):\n",
    "    os.makedirs(\"build\")\n",
    "\n",
    "unique_chars = {}  # 存储字符和对应的token ID\n",
    "\n",
    "for id in tqdm(range(len(tokenizer.get_vocab()))):\n",
    "    token = tokenizer.decode(id)\n",
    "    if token.startswith(\"<｜\"):\n",
    "        continue\n",
    "    # 对于每个字符，记录最小的token ID\n",
    "    for char in token:\n",
    "        if char not in unique_chars:\n",
    "            unique_chars[char] = id\n",
    "\n",
    "# count total unique chars\n",
    "print(f\"Total unique chars: {len(unique_chars)}\")\n",
    "\n",
    "sorted_chars = sorted(unique_chars.items(), key=lambda x: x[1])\n",
    "# write to file - 按照token ID排序\n",
    "with open(\"./build/chars.txt\", \"w\") as f:\n",
    "    # 按照token ID排序输出\n",
    "    for char, token_id in sorted_chars:\n",
    "        f.write(char + \"\\n\")\n",
    "\n",
    "print(f\"Wrote {len(unique_chars)} unique characters to unique_chars.txt (sorted by token ID)\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "82281aaa",
   "metadata": {},
   "source": [
    "## 从字体中提取子集\n",
    "\n",
    "字体文件可以从 https://www.alibabafonts.com/ 或 https://fonts.google.com/noto 下载到 fonts 目录下"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "031a7a93",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: fonttools in /home/terrence/miniconda3/envs/dev/lib/python3.12/site-packages (4.59.0)\n"
     ]
    }
   ],
   "source": [
    "!pip install fonttools"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ac8117b0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Building subsetter\n",
      "basic_unicodes: Added 901 chars from assets\n",
      "common_unicodes: Added chars: 7423\n",
      "Subsetting 7 fonts\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 7/7 [00:02<00:00,  3.40it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Merging 7 fonts\n",
      "Merged font saved to ttf/puhui-basic.ttf\n",
      "Subsetting 7 fonts\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 7/7 [00:06<00:00,  1.02it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Merging 7 fonts\n",
      "Merged font saved to ttf/puhui-common.ttf\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import shutil\n",
    "import json\n",
    "from fontTools.subset import Subsetter, Options, load_font, save_font\n",
    "from fontTools.merge import Merger\n",
    "from fontTools.ttLib.scaleUpem import scale_upem\n",
    "\n",
    "print(f\"Building subsetter\")\n",
    "basic_unicodes = set(range(0x20, 0x7f)) | set(range(0xA1, 0x100))\n",
    "for parent, dirs, files in os.walk(\"../../main/assets/locales\"):\n",
    "    for filename in files:\n",
    "        if filename == 'language.json':\n",
    "            with open(os.path.join(parent, filename), 'r') as f:\n",
    "                strings = json.load(f)[\"strings\"]\n",
    "                # Add all values to unicodes\n",
    "                for value in strings.values():\n",
    "                    for char in value:\n",
    "                        basic_unicodes.add(ord(char))\n",
    "print(f\"basic_unicodes: Added {len(basic_unicodes)} chars from assets\")\n",
    "\n",
    "common_unicodes = basic_unicodes.copy()\n",
    "for char, token_id in sorted_chars:\n",
    "    common_unicodes.add(ord(char))\n",
    "print(f\"common_unicodes: Added chars: {len(common_unicodes)}\")\n",
    "\n",
    "font_list = []\n",
    "\n",
    "def build_ttf(font_type, font_style, font_name, unicodes):\n",
    "    global font_list\n",
    "    # font_list = [\n",
    "    #     f\"fonts/Noto_Sans/static/NotoSans-{font_style}.ttf\",\n",
    "    #     f\"fonts/Noto_Emoji/static/NotoEmoji-{font_style}.ttf\",\n",
    "    #     f\"fonts/Noto_Sans_JP/static/NotoSansJP-{font_style}.ttf\",\n",
    "    #     f\"fonts/Noto_Sans_KR/static/NotoSansKR-{font_style}.ttf\",\n",
    "    #     f\"fonts/Noto_Sans_SC/static/NotoSansSC-{font_style}.ttf\",\n",
    "    #     f\"fonts/Noto_Sans_TC/static/NotoSansTC-{font_style}.ttf\",\n",
    "    #     f\"fonts/Noto_Sans_Thai/static/NotoSansThai-{font_style}.ttf\"\n",
    "    # ]\n",
    "    font_list = [\n",
    "        f\"fonts/AlibabaSans/AlibabaSans-{font_style}/AlibabaSans-{font_style}.ttf\",\n",
    "        f\"fonts/AlibabaPuHuiTi-3/AlibabaPuHuiTi-3-55-{font_style}/AlibabaPuHuiTi-3-55-{font_style}.ttf\",\n",
    "        f\"fonts/AlibabaSansJP/AlibabaSansJP-{font_style}/AlibabaSansJP-{font_style}.ttf\",\n",
    "        f\"fonts/AlibabaSansKR/AlibabaSansKR-{font_style}/AlibabaSansKR-{font_style}.ttf\",\n",
    "        f\"fonts/AlibabaSansTC/AlibabaSansTC-55/AlibabaSansTC-55.ttf\",\n",
    "        f\"fonts/AlibabaSansThai/AlibabaSansThai-Rg/AlibabaSansThai-Rg.ttf\",\n",
    "        f\"fonts/AlibabaSansViet/AlibabaSansViet-Rg/AlibabaSansViet-Rg.ttf\",\n",
    "    ]\n",
    "\n",
    "    if not os.path.exists(f\"build/subsets\"):\n",
    "        os.makedirs(f\"build/subsets\")\n",
    "\n",
    "    print(f\"Subsetting {len(font_list)} fonts\")\n",
    "    subset_fonts = []\n",
    "    subsetter = Subsetter(Options())\n",
    "    subsetter.populate(unicodes=list(unicodes))\n",
    "    # 遍历 font_list，提取每个字体中的字符\n",
    "    for font_path in tqdm(font_list):\n",
    "        if not os.path.exists(font_path):\n",
    "            print(f\"Font {font_path} not found\")\n",
    "            continue\n",
    "        font = load_font(font_path, Options())\n",
    "        font_file = font_path.split('/')[-1].split('.')[0]\n",
    "        subsetter.subset(font)\n",
    "        scale_upem(font, 1000)\n",
    "        save_path = f\"build/subsets/{font_file}.ttf\"\n",
    "        font.save(save_path)\n",
    "        subset_fonts.append(save_path)\n",
    "\n",
    "    # 合并所有字体，保存到 build/puhui-{len(unicodes)}-{style}.ttf\n",
    "    print(f\"Merging {len(subset_fonts)} fonts\")\n",
    "    output_path = f\"ttf/{font_type}-{font_name}.ttf\"\n",
    "    cmd = f\"fonttools merge {\" \".join(subset_fonts)} --output-file={output_path} --drop-tables=vhea,vmtx\"\n",
    "    os.system(cmd)\n",
    "    print(f\"Merged font saved to {output_path}\")\n",
    "\n",
    "\n",
    "build_ttf(\"puhui\", \"Regular\", \"basic\", basic_unicodes)\n",
    "build_ttf(\"puhui\", \"Regular\", \"common\", common_unicodes)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f1cb872",
   "metadata": {},
   "source": [
    "## 生成不同 size 与 bpp 的点阵字体"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "49c783db",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "字体: ttf/puhui-common.ttf, 大小: 20px, BPP: 1\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAArcAAAAeCAYAAAA2ETZ4AAAM60lEQVR4Ae2dgW7kyA1Ez8H+W/JXufxV8nWb5R6er0CTLXarNaMZcwChu8mqIlmS14Lh8338/PX5oz/tQDvQDrQD7UA70A60A+3AGzjw4w1m6BHagXagHWgH2oF2oB1oB6504M//jdX//Oc4vyt71MevOv/YVat12oF2oB1oB9qBdqAdaAfagWc70C+3z74DXb8daAfagXagHWgH2oF2YJsD/XK7zcoWagfagXagHWgH2oF2oB14tgP9cvvsO9D124F2oB1oB9qBdqAdaAe2OdD/Qdk2K1uoHWgH2oF2oB1oB9qB93Tg4z//+hzs57//+7l/xkZ7sfr0Q7xfbp9xVx5Y8+Pj44/+a297Dd/hqWnYp+/N3nvTausO9DO57l0z24Hv4oC9RPIC+ayZqc8LrfVBjJ761xJw4g1Wvjkxij8TP1qNt8o90n50/qpZ3sWfo/uR+ZfFj/Qelb9LfyvPSaX3CgavwfqV/BUrtUbahhl9KhojPjnV0T15v4KJVo/t82s4YPdSP/6suTvsefYqvcxgK3qrGP9yuaqzytMXXdP44H/iEN3s7KdKHqs4n6NRxRD73YB76MhlePKsWi/iaB4Oa4Qn53mK9Tk4uire4hHHY5S/ildNNDSmNbJ9xiOe8SxerVXR2lWn2tOonubo/YzuqobxtG5Fp4LR+XSfcbO4cqt709KZqrwMt9rbKi/rw+Irs1X6qGCoT394DNfixBSrMbhwopxywbNmeDhHecONMNQZ9ac53cNlJWfnqOZMHk3WSI9cr49xQO+fVXz0PfH1mTrqA2yUg8c6g4WzvP76+7Kjl9hKv8u1hcjMEvqy/f1rCQC1MYvZ5WNfFFxA8aQiLXKzeHi20rfGsn1UJ8Oim3GyuOnBVW1iyrOYXRqDM4uHF2lZDj1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P3y23uzUtlsi/wLB4NV8FWMGhXv5GC37XO9DiqWdGpYLIaZ7iZZsfv5cBd7vFVfVyla3fxCu0rNO/1xH2fbp71/eX7OPzak/bL7Wvfv1t3/8rfSF6591s/FN1cO9AOlF/c+9+hrw8LL7XtzVdvOvK3A/1y+7cXvWsH2oF2oB1oB27pQL/M/XVb2odbPp63a+rj14Py83ZddUPtQDvQDrQD7UA70A60A+3AggNb/87tQv2mtAPtQDvQDrQD7UA70A60A9sc+D8sOrkd+DEzQwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<PIL.Image.Image image mode=RGBA size=695x30>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "字体: ttf/puhui-common.ttf, 大小: 20px, BPP: 2\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAuYAAAAeCAYAAABgx9sOAAAUXUlEQVR4Ae2dW5ZcN3JFSS3NxnPwb3sATQ3G/rD8YQ+G7AG4f+0x2NORcxe5S6eCAVzcm1mskgysdQkgHidOHCCzsh6t/vjbbXzYYyuwFdgKbAW2AluBrcBWYCuwFXhTBX5+0+q7+FZgK7AV2ApsBbYCW4GtwFbgkQr8+vdjtF//chzzyIgVTrd6Pz2y5sbaCmwFtgJbga3AVmArsBXYCmwFrimwP5hf021nbQW2AluBrcBWYCuwFdgKbAUeqsD+YP5QOTfYVmArsBXYCmwFtgJbga3AVuCaAvuD+TXddtZWYCuwFdgKbAW2AluBrcBW4KEK7A/mD5Vzg20FtgJbga3AVmArsBXYCry1Ar98+fcPH//tnz4wv6cBJx+5ffmf/3qyMe8P5u/ptF6Jy8ePH18g//LLLx+q7UXAwebLly935R/Av4n7Xk060o/U6ZFYHddt++MowF34ow3eb3iNPWI88rX6KC3BSaxcP6LnjbEV2AqcU4APuF/+978//Pav//k0n8t+vWg+kDM+//Wfnx7W2ODq2P+5RJX4k87dF0O+aHz69OnhHXe1apHPnz9X03R/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
      "text/plain": [
       "<PIL.Image.Image image mode=RGBA size=742x30>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "字体: ttf/puhui-common.ttf, 大小: 20px, BPP: 3\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAuYAAAAeCAYAAABgx9sOAAAZGElEQVR4Ae2dTbIdSVJGn8pqBTCjp6UlsIZu1RLoEcwYlDYAZl0YrEBl1swY0QuAgVS9hWYJ0hQYAUsQebL6vPLnzyMyIu99f+pws1RERvjP55975M17pep+9XmTmyWLgcXAYmAxsBhYDCwGFgOLgcXAkzLw9ZNGX8EXA4uBxcBiYDGwGFgMLAYWA9dk4PvfH3v7/pfHOtfUGMG0xfvqmjGXr8XAYmAxsBhYDCwGFgOLgcXAYuAcA+vF/Bxvy2oxsBhYDCwGFgOLgcXAYmAxcFUG1ov5VelczhYDi4HFwGJgMbAYWAwsBhYD5xhYL+bneFtWi4HFwGJgMbAYWAwsBhYDi4GrMrBezK9K53K2GLjLwKdPn+4urLvFwGJgMbAYWAwsBh6cgW9/9/c3r/7hVzdvP/z2wWONBvj0v/918/rdX++4wAZG1j58/I99jXG9mI+y+UL1eDF8/fr1TXxBfPv27c2rV69OZ/Thw4eL7E8HfkDDSzmpoP3www/3uK/0Rtb0NaK7dL5sBjh/z0l4tsTnS4WN5823335bbU2vcVZ5po3IES64PNIZicP55FKu5Vd/a1wMLAbmGOAF9+P//OfN59/8ePPDH/59zvgBtd/869/t3t//1T/ecCGvf/ibDeO/7XP+WP9zibdUfJmTd+/e7R8833zzzW2CfGi8efPm9n520vog4wOztUcMMIBnRuKH3Yydut99953T7ngpJ5VzYsMJOc/mXfnrcVvpP/UaeHmBgoecf2/vqXFX8XmpJI+Zc+PL2WgPVnGrNbFkTitd1zhH6H/8+NGle6M1QW8EMzjIMQr8vH//Pi4dzsEGrtF8wMl1JJw9fcfnn3b4IIdRzL16EosY8nbkl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5S67gwv5cGVgv4depzOg/1/NvUa8T9cv34ks5Pyytz4Avv96PmeH6pyyPyfaKtRhYDCwGFgOLgUdmgB8QjiTrcL/+iU6btZf+o1I7s7Xz1Aysf8ry1BVY8RcDi4HFwGJgMbAYWAwsBhYDGwNfLRYWA4uBxcBiYDGwGFgMLAYWA4uBp2fg/wGAAXPsx8lNbgAAAABJRU5ErkJggg==",
      "text/plain": [
       "<PIL.Image.Image image mode=RGBA size=742x30>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "字体: ttf/puhui-common.ttf, 大小: 20px, BPP: 4\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAuYAAAAeCAYAAABgx9sOAAAddUlEQVR4Ae3dP6wvx1UH8J8jF0QixXMFlLao6LBrKluhoIzdIUFjV6SNgQJTgGI60jkIIVHaLQWRXSHoYqiokF8JqWKkRArdYz+Lv5fzmzuzv93f/b3nZ2eOtG92Z86cP99z5szs3uvrF54sdJo0EZgITAQmAhOBicBEYCIwEZgIfKkIvPilap/KJwITgYnARGAiMBGYCEwEJgK3ROC9H12W9t63L/PckmOPTYu+b9xS55Q1EZgITAQmAhOBicBEYCIwEZgIXIfAPJhfh9ucNRGYCEwEJgITgYnARGAiMBG4KQLzYH5TOKewicBEYCIwEZgITAQmAhOBicB1CMyD+XW4zVkTgYnARGAiMBGYCEwEJgITgZsiMA/mN4VzCpsInCPw+PHj8475NBGYCEwEJgITgYnAU0fgjb//49NL73/n9O4nf/vUde1V8Ol//sfplb/+g9MLf/676/XWR39xevz5f50+efyv67N2Hsz3ovkV5XMwfO21106ffvrpnQfvvvvu6aWXXrp7Pnrz0UcfnV544YXT559/fnTqc8v/UEx6jv3whz88vfLKK6dbHM7JEsdJE4FPPvnkuVp7aotrVA/0qxdvvfXWTYJnre5ZC/ReWntqWa2N1xr4/vvvn6zR0K3kRt5sJwITgWMIfPTv/3T6/H9+dvrs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syFnlyhj+ZS+ayQW/6lLlp2UJOuyYyXls2kX+JfAll07LZ3eNnb75MqlsPITroEsPlYPEQUev6Dr5iktg/VO6DjPpicmJ0qc6ot7W2p0aKmVhMGiOgNqsLlzAeS5gjN0fgvR9dFvnety/z3JJjj02LvhdvqXPKen4RyEYeCxXdHBTbsfbZHJuNwtPbxPBnTg6bnvcUc/xk93j3HOrjz7Xt3sPCSH5eVsixCfcOatHBV4eKEIy8jBi/RDZMhx+HoCoj84K3w0FLe+S3c74uz3t9x1dfmkb+O6TsOVyab5O+RPTutZEsvNaLXMqz2LNd7smTHvVswd/L1978S32xZ4uPnXuw82LhoCPPXcGH34gcPM8T9fB9nuybtjw9BOyLrj0vp0/Piin564TA/GL+dYrmV9AXX3NueUB41hD46uYrnheLHCCetQ1T30Tg64iAl1AHnhzIrS8vHrd6mfg6YtbzaX4x76Hy8D75mcvLop9Wzj3g4bjeTMKer9PP6RfzeTC/WRZMQROBicBEYCIwEXi+EPBi43J43CIfGRwsc7icv8qyhdZp/Q9c81Pk+WFmG6svZXQezL8U2KfSicBEYCIwEZgITAQmAhOBicA5AvNgfo7HfJoITAQmAhOBicBEYCIwEZgITASOIfCNY+yTeyIwEZgITAQmAhOBicBEYCIwEXgaCPwvCd/rJE+psL0AAAAASUVORK5CYII=",
      "text/plain": [
       "<PIL.Image.Image image mode=RGBA size=742x30>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import os\n",
    "from PIL import Image\n",
    "import json\n",
    "from IPython.display import display\n",
    "\n",
    "# https://github.com/78/lv_font_conv (Support cbin format)\n",
    "lv_font_conv = \"node ./tmp/lv_font_conv/lv_font_conv.js\"\n",
    "flags = \"--force-fast-kern-format --no-compress --no-prefilter \"\n",
    "\n",
    "def preview_font(font_path, size, bpp):\n",
    "    symbols_str = \"0123456789你好，正在充电！Helloこんにちは안녕하세요ЗдравствуйтеOláสวัสดี\"\n",
    "    output = \"./build/preview\"\n",
    "    if os.path.exists(output):\n",
    "        shutil.rmtree(output)\n",
    "    os.makedirs(output)\n",
    "    cmd = f\"{lv_font_conv} {flags} --font {font_path} --format dump --bpp {bpp} -o {output} --size {size} --symbols {symbols_str} \"\n",
    "    os.system(cmd)\n",
    "    \n",
    "    # 读取字体信息\n",
    "    font_info_path = os.path.join(output, \"font_info.json\")\n",
    "    if not os.path.exists(font_info_path):\n",
    "        print(\"未找到font_info.json文件\")\n",
    "        return\n",
    "        \n",
    "    with open(font_info_path, 'r', encoding='utf-8') as f:\n",
    "        font_info = json.load(f)\n",
    "    \n",
    "    # 获取字体高度信息\n",
    "    font_height = font_info.get('size', size)\n",
    "    ascent = font_info.get('ascent', font_height)\n",
    "    descent = font_info.get('descent', 0)\n",
    "    \n",
    "    # 收集所有PNG文件并按照字符顺序排序\n",
    "    png_files = []\n",
    "    char_positions = {}  # 存储每个字符在原始字符串中的位置\n",
    "    \n",
    "    for i, char in enumerate(symbols_str):\n",
    "        unicode_hex = f\"{ord(char):x}.png\"\n",
    "        png_path = os.path.join(output, unicode_hex)\n",
    "        if os.path.exists(png_path):\n",
    "            png_files.append((char, png_path, i))\n",
    "            char_positions[char] = i\n",
    "    \n",
    "    # 按照原始字符串顺序排序\n",
    "    png_files.sort(key=lambda x: x[2])\n",
    "    \n",
    "    if not png_files:\n",
    "        print(\"未找到任何PNG文件\")\n",
    "        return\n",
    "    \n",
    "    # 加载所有图片并计算总尺寸\n",
    "    images = []\n",
    "    total_width = 0\n",
    "    max_height = 0\n",
    "    \n",
    "    for char, png_path, _ in png_files:\n",
    "        try:\n",
    "            img = Image.open(png_path).convert('RGBA')\n",
    "            images.append((char, img))\n",
    "            total_width += img.width + 2  # 添加2像素间距\n",
    "            max_height = max(max_height, img.height)\n",
    "        except Exception as e:\n",
    "            print(f\"无法加载图片 {png_path}: {e}\")\n",
    "            continue\n",
    "    \n",
    "    if not images:\n",
    "        print(\"没有成功加载任何图片\")\n",
    "        return\n",
    "    \n",
    "    # 移除最后一个字符的间距\n",
    "    total_width -= 2\n",
    "    \n",
    "    # 创建预览图画布，使用字体高度作为画布高度\n",
    "    canvas_height = max(max_height, font_height + 10)  # 添加一些padding\n",
    "    canvas = Image.new('RGBA', (total_width, canvas_height), (255, 255, 255, 255))\n",
    "    \n",
    "    # 拼接图片\n",
    "    x_offset = 0\n",
    "    for char, img in images:\n",
    "        # 计算垂直居中位置\n",
    "        y_offset = (canvas_height - img.height) // 2\n",
    "        canvas.paste(img, (x_offset, y_offset), img)\n",
    "        x_offset += img.width + 2\n",
    "    \n",
    "    # 打印字符信息\n",
    "    print(f\"字体: {font_path}, 大小: {size}px, BPP: {bpp}\")\n",
    "    \n",
    "    # 在 notebook 中直接显示图片\n",
    "    display(canvas)\n",
    "    \n",
    "    return canvas\n",
    "\n",
    "# 调用函数并显示图片\n",
    "font_size = 20\n",
    "for bpp in [1, 2, 3, 4]:\n",
    "    preview_image = preview_font(\"ttf/puhui-common.ttf\", font_size, bpp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "44c7121f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating src/font_puhui_basic_14_1.c...\n",
      "Generating src/font_puhui_basic_16_4.c...\n",
      "Generating src/font_puhui_basic_20_4.c...\n",
      "Generating src/font_puhui_basic_30_4.c...\n"
     ]
    }
   ],
   "source": [
    "\n",
    "flags = \"--force-fast-kern-format --no-compress --no-prefilter \"\n",
    "\n",
    "def generate_font_source(font_path, name, size, bpp):\n",
    "    output = f\"src/font_{name}_{size}_{bpp}.c\"\n",
    "    print(f\"Generating {output}...\")\n",
    "    cmd = f\"{lv_font_conv} {flags} --font {font_path} --format lvgl --lv-include lvgl.h --bpp {bpp} -o {output} --size {size} -r 0x0-0xfffff\"\n",
    "    os.system(cmd)\n",
    "\n",
    "generate_font_source(\"ttf/puhui-basic.ttf\", \"puhui_basic\", 14, 1)\n",
    "generate_font_source(\"ttf/puhui-basic.ttf\", \"puhui_basic\", 16, 4)\n",
    "generate_font_source(\"ttf/puhui-basic.ttf\", \"puhui_basic\", 20, 4)\n",
    "generate_font_source(\"ttf/puhui-basic.ttf\", \"puhui_basic\", 30, 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "0aa3e502",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating cbin/font_puhui_common_14_1.bin...\n",
      "Forced faster kerning format (via classes). Size increase is 708 bytes.\n",
      "Generating cbin/font_puhui_common_16_4.bin...\n",
      "Forced faster kerning format (via classes). Size increase is 708 bytes.\n",
      "Generating cbin/font_puhui_common_20_4.bin...\n",
      "Forced faster kerning format (via classes). Size increase is 708 bytes.\n",
      "Generating cbin/font_puhui_common_30_4.bin...\n",
      "Forced faster kerning format (via classes). Size increase is 708 bytes.\n"
     ]
    }
   ],
   "source": [
    "def generate_font_cbin(font_path, name, size, bpp):\n",
    "    output = f\"cbin/font_{name}_{size}_{bpp}.bin\"\n",
    "    print(f\"Generating {output}...\")\n",
    "    cmd = f\"{lv_font_conv} {flags} --font {font_path} --format cbin --bpp {bpp} -o {output} --size {size} -r 0x0-0xfffff\"\n",
    "    os.system(cmd)\n",
    "\n",
    "# Generate cbin font\n",
    "generate_font_cbin(\"ttf/puhui-common.ttf\", \"puhui_common\", 14, 1)\n",
    "generate_font_cbin(\"ttf/puhui-common.ttf\", \"puhui_common\", 16, 4)\n",
    "generate_font_cbin(\"ttf/puhui-common.ttf\", \"puhui_common\", 20, 4)\n",
    "generate_font_cbin(\"ttf/puhui-common.ttf\", \"puhui_common\", 30, 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "fb65161e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== 开始并行生成字体bin文件 ===\n",
      "开始并行生成 28 个字体文件，使用 8 个进程...\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "生成字体文件:   0%|          | 0/28 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating build/full/AlibabaSans-Regular_30_4.bin...Generating build/full/AlibabaPuHuiTi-3-55-Regular_30_4.bin...Generating build/full/AlibabaPuHuiTi-3-55-Regular_14_1.bin...Generating build/full/AlibabaSans-Regular_16_4.bin...Generating build/full/AlibabaPuHuiTi-3-55-Regular_16_4.bin...Generating build/full/AlibabaPuHuiTi-3-55-Regular_20_4.bin...Generating build/full/AlibabaSans-Regular_14_1.bin...Generating build/full/AlibabaSans-Regular_20_4.bin...\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "生成字体文件:   4%|▎         | 1/28 [00:01<00:29,  1.09s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating build/full/AlibabaSansJP-Regular_14_1.bin...\n",
      "Generating build/full/AlibabaSansJP-Regular_16_4.bin...\n",
      "Generating build/full/AlibabaSansJP-Regular_20_4.bin...\n",
      "Generating build/full/AlibabaSansJP-Regular_30_4.bin...\n",
      "Generating build/full/AlibabaSansKR-Regular_14_1.bin...\n",
      "Generating build/full/AlibabaSansKR-Regular_16_4.bin...\n",
      "Generating build/full/AlibabaSansKR-Regular_20_4.bin...\n",
      "Generating build/full/AlibabaSansKR-Regular_30_4.bin...\n",
      "Generating build/full/AlibabaSansTC-55_14_1.bin...\n",
      "Generating build/full/AlibabaSansTC-55_16_4.bin...\n",
      "Generating build/full/AlibabaSansTC-55_20_4.bin...\n",
      "Generating build/full/AlibabaSansTC-55_30_4.bin...\n",
      "Generating build/full/AlibabaSansThai-Rg_14_1.bin...\n",
      "Forced faster kerning format (via classes). Size increase is 9024 bytes.\n",
      "Generating build/full/AlibabaSansThai-Rg_16_4.bin...\n",
      "Generating build/full/AlibabaSansThai-Rg_20_4.bin...\n",
      "Generating build/full/AlibabaSansThai-Rg_30_4.bin...\n",
      "Generating build/full/AlibabaSansViet-Rg_14_1.bin...\n",
      "Generating build/full/AlibabaSansViet-Rg_16_4.bin...\n",
      "Generating build/full/AlibabaSansViet-Rg_20_4.bin...\n",
      "Generating build/full/AlibabaSansViet-Rg_30_4.bin...\n",
      "Forced faster kerning format (via classes). Size increase is 9024 bytes.\n",
      "Forced faster kerning format (via classes). Size increase is 9024 bytes.\n",
      "Forced faster kerning format (via classes). Size increase is 9024 bytes.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "生成字体文件:  18%|█▊        | 5/28 [03:36<17:36, 45.94s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Forced faster kerning format (via classes). Size increase is 12716 bytes.\n",
      "Forced faster kerning format (via classes). Size increase is 12716 bytes.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "生成字体文件:  21%|██▏       | 6/28 [03:37<13:01, 35.52s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Forced faster kerning format (via classes). Size increase is 12716 bytes.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "生成字体文件: 100%|██████████| 28/28 [03:53<00:00,  8.34s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Forced faster kerning format (via classes). Size increase is 12716 bytes.\n",
      "完成生成 28 个字体文件\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['build/full/AlibabaSans-Regular_14_1.bin',\n",
       " 'build/full/AlibabaSans-Regular_16_4.bin',\n",
       " 'build/full/AlibabaSans-Regular_20_4.bin',\n",
       " 'build/full/AlibabaSans-Regular_30_4.bin',\n",
       " 'build/full/AlibabaPuHuiTi-3-55-Regular_14_1.bin',\n",
       " 'build/full/AlibabaPuHuiTi-3-55-Regular_16_4.bin',\n",
       " 'build/full/AlibabaPuHuiTi-3-55-Regular_20_4.bin',\n",
       " 'build/full/AlibabaPuHuiTi-3-55-Regular_30_4.bin',\n",
       " 'build/full/AlibabaSansJP-Regular_14_1.bin',\n",
       " 'build/full/AlibabaSansJP-Regular_16_4.bin',\n",
       " 'build/full/AlibabaSansJP-Regular_20_4.bin',\n",
       " 'build/full/AlibabaSansJP-Regular_30_4.bin',\n",
       " 'build/full/AlibabaSansKR-Regular_14_1.bin',\n",
       " 'build/full/AlibabaSansKR-Regular_16_4.bin',\n",
       " 'build/full/AlibabaSansKR-Regular_20_4.bin',\n",
       " 'build/full/AlibabaSansKR-Regular_30_4.bin',\n",
       " 'build/full/AlibabaSansTC-55_14_1.bin',\n",
       " 'build/full/AlibabaSansTC-55_16_4.bin',\n",
       " 'build/full/AlibabaSansTC-55_20_4.bin',\n",
       " 'build/full/AlibabaSansTC-55_30_4.bin',\n",
       " 'build/full/AlibabaSansThai-Rg_14_1.bin',\n",
       " 'build/full/AlibabaSansThai-Rg_16_4.bin',\n",
       " 'build/full/AlibabaSansThai-Rg_20_4.bin',\n",
       " 'build/full/AlibabaSansThai-Rg_30_4.bin',\n",
       " 'build/full/AlibabaSansViet-Rg_14_1.bin',\n",
       " 'build/full/AlibabaSansViet-Rg_16_4.bin',\n",
       " 'build/full/AlibabaSansViet-Rg_20_4.bin',\n",
       " 'build/full/AlibabaSansViet-Rg_30_4.bin']"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import multiprocessing as mp\n",
    "from functools import partial\n",
    "import os\n",
    "import shutil\n",
    "\n",
    "build_dir = \"build/full\"\n",
    "if os.path.exists(build_dir):\n",
    "    shutil.rmtree(build_dir)\n",
    "os.makedirs(build_dir)\n",
    "\n",
    "def generate_font_full_bin(args):\n",
    "    \"\"\"单个字体生成任务\"\"\"\n",
    "    font_path, name, size, bpp = args\n",
    "    output = f\"{build_dir}/{name}_{size}_{bpp}.bin\"\n",
    "    print(f\"Generating {output}...\")\n",
    "    cmd = f\"lv_font_conv {flags} --font {font_path} --format bin --bpp {bpp} -o {output} --size {size} -r 0x0-0xfffff\"\n",
    "    os.system(cmd)\n",
    "    return output\n",
    "\n",
    "# 创建任务列表\n",
    "def create_font_tasks(font_list, task_type=\"bin\"):\n",
    "    \"\"\"创建字体生成任务列表\"\"\"\n",
    "    tasks = []\n",
    "    sizes_bpps = [(14, 1), (16, 4), (20, 4), (30, 4)]\n",
    "    \n",
    "    for font_path in font_list:\n",
    "        font_name = font_path.split('/')[-1].split('.')[0]\n",
    "        for size, bpp in sizes_bpps:\n",
    "            tasks.append((font_path, font_name, size, bpp))\n",
    "    \n",
    "    return tasks\n",
    "\n",
    "\n",
    "# 多进程生成字体文件\n",
    "def generate_fonts_parallel(font_list, task_type=\"bin\", max_workers=None):\n",
    "    \"\"\"使用进程池并行生成字体文件\"\"\"\n",
    "    if max_workers is None:\n",
    "        max_workers = min(mp.cpu_count(), len(font_list) * 4)  # 每个字体4个任务\n",
    "    \n",
    "    tasks = create_font_tasks(font_list, task_type)\n",
    "    \n",
    "    print(f\"开始并行生成 {len(tasks)} 个字体文件，使用 {max_workers} 个进程...\")\n",
    "    \n",
    "    with mp.Pool(processes=max_workers) as pool:\n",
    "        if task_type == \"bin\":\n",
    "            results = list(tqdm(\n",
    "                pool.imap(generate_font_full_bin, tasks),\n",
    "                total=len(tasks),\n",
    "                desc=\"生成字体文件\"\n",
    "            ))\n",
    "        else:\n",
    "            results = list(tqdm(\n",
    "                pool.imap(generate_font_source_mp, tasks),\n",
    "                total=len(tasks),\n",
    "                desc=\"生成字体源码\"\n",
    "            ))\n",
    "    \n",
    "    print(f\"完成生成 {len(results)} 个字体文件\")\n",
    "    return results\n",
    "\n",
    "# 并行生成bin文件\n",
    "print(\"=== 开始并行生成字体bin文件 ===\")\n",
    "generate_fonts_parallel(font_list, task_type=\"bin\", max_workers=8)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "dev",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
